package org.tity.test.java.lambda;

import java.util.function.IntUnaryOperator;

import org.junit.Test;

public class Lamdba1 {

	@Test
	public void testGetNamesFromList() {

		Plus2 p2 = (int a, int b) -> a + b;
		Plus3 p3 = (int a, int b,int c) ->{ return a + b + c;};
		Plus p = (int[] x) -> {
			int z=0;
			for (int i : x) {
				z+=i;
			}
			return z;
		};
		
		OZ oz=() -> { return System.currentTimeMillis()+" : this is OZ";};
		
		String ozp=oz.doIt();
		
		System.err.println(ozp);
		
		int sum2 = plus2(2, 5, p2);
		int sum3 = plus3(2, 5, 5,p3);
		int sum = plus(p,5,7,8,0,6);
	
		
		System.out.println(sum2+","+sum3+","+sum);

		IntUnaryOperator mapper = (int i)  -> {
			return i * 3;
		};

	}
	
	interface Plus3 {
		int doIt(int a, int b,int c);
	}

	interface Plus2 {
		int doIt(int a, int b);
	}
	
	interface Plus {
		int doIt(int... a);
	}
	
	interface OZ {
		String doIt();
	}
	
	private int plus(Plus plus , int... x) {
		return plus.doIt(x);
	}

	private int plus3(int a, int b, int c,Plus3 plus) {
		return plus.doIt(a, b,c);
	}
	
	private int plus2(int a, int b, Plus2 mathOperation) {
		return mathOperation.doIt(a, b);
	}

}
